<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('试题管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul> 
                            <li>
                                <label>类型：</label>
                                <select name="type" th:with="type=${@dict.getType('shiti_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>问题：</label>
                                <input type="text" name="title"/>
                            </li>
                            <li>
                                <label>答案A：</label>
                                <input type="text" name="qa"/>
                            </li>
                            <li>
                                <label>答案B：</label>
                                <input type="text" name="qb"/>
                            </li>
                            <li>
                                <label>答案C：</label>
                                <input type="text" name="qc"/>
                            </li>
                            <li>
                                <label>答案D：</label>
                                <input type="text" name="qd"/>
                            </li>
                            <li>
                                <label>简答题答案：</label>
                                <input type="text" name="qe"/>
                            </li>
                            <li>
                                <label>选择题答案：</label>
                                <select name="ans" th:with="type=${@dict.getType('xuanze_ans')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
 
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:shiti:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:shiti:remove')}]];
        var typeDatas = [[${@dict.getType('shiti_type')}]];
        var ansDatas = [[${@dict.getType('xuanze_ans')}]];
        var prefix = ctx + "system/shiti";
        var pid = getUrlParam('pid');
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add?pid="+pid,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                queryParams: queryParams,
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "试题管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                }, 
                {
                    field: 'type',
                    title: '类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'title',
                    title: '问题'
                },
                {
                    field: 'qa',
                    title: '答案A'
                },
                {
                    field: 'qb',
                    title: '答案B'
                },
                {
                    field: 'qc',
                    title: '答案C'
                },
                {
                    field: 'qd',
                    title: '答案D'
                },
                {
                    field: 'qe',
                    title: '简答题答案'
                },
                {
                    field: 'ans',
                    title: '选择题答案',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(ansDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' " href="javascript:void(0)" onclick="$.modal.openTab(\'查看\',\''+prefix+'/statistic?pid=' + row.id + '\')"> 查看答题分析</a>  ')  
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function queryParams(params) {
        	var search = $.table.queryParams(params);
        	search.sectionId =pid;
        	return search;
        }
    </script>
    <script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
	<div class="col-xs-offset-1">
		<input type="file" id="file" name="file"/>

		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>
</script>
</body>
</html>